package Wormish.agiletre.se;

import android.media.MediaPlayer;
import android.util.Log;

public class SoundSystemBlaster {
	
    public MediaPlayer[] soundArray = new MediaPlayer[11];
    public final int 
    	EXPLOSION=0,
    	JUMP=1,
    	ROPE=2,
    	SHOT=3,
    	HIT=4,
    	BLOB=5,
    	BANANA=6,
    	SHOTGUN=7,
    	MACHINEGUN=8,
    	WIN=9,
    	LOSE=10
    	;
    
    public SoundSystemBlaster(){
    	soundArray[EXPLOSION] = MediaPlayer.create(GameThread.mContext, R.raw.explosion2);
    	soundArray[JUMP] = MediaPlayer.create(GameThread.mContext, R.raw.huh);
    	soundArray[ROPE] = MediaPlayer.create(GameThread.mContext, R.raw.boink);
    	soundArray[SHOT] = MediaPlayer.create(GameThread.mContext, R.raw.coachgun);
    	soundArray[HIT] = MediaPlayer.create(GameThread.mContext, R.raw.wooow);
    	soundArray[BLOB] = MediaPlayer.create(GameThread.mContext, R.raw.lazer);
    	soundArray[BANANA] = MediaPlayer.create(GameThread.mContext, R.raw.blomp_skott);
    	soundArray[SHOTGUN] = MediaPlayer.create(GameThread.mContext, R.raw.shotgun);
    	soundArray[MACHINEGUN] = MediaPlayer.create(GameThread.mContext, R.raw.long_scream);
    	soundArray[WIN] = MediaPlayer.create(GameThread.mContext, R.raw.cartoon_laughter);
    	soundArray[LOSE] = MediaPlayer.create(GameThread.mContext, R.raw.sonofabitch);
    }
    
    public void play(int sound){
    	//soundArray[sound].start();
    	/*if(!soundArray[sound].isPlaying()){
    		reset(sound);
    	}*/
    	/*if(soundArray[sound].isPlaying() && soundArray[sound].getCurrentPosition()>100){
    		soundArray[sound].stop();
    		reset(sound);
    	}*/
    	if(main.soundOn){
    		soundArray[sound].start();
    	}
    }
    
    public void reset(int sound){
    	soundArray[sound].reset();
    	try{
    		soundArray[sound].prepare();
    	}
    	catch(Exception e){}
    }
    
    public void unload(){
    	for(int i=0; i<soundArray.length;i++){
    		soundArray[i].release();
    	}
    }

}
